package com.hzy.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;

/**
 * @Package: com.hzy.aop
 * @ClassName: ErrorLogger
 * @Author: 862982795
 * @CreateTime: 2021/07/05 19:59
 * @Description:定义包含增强方法的 JavaBean
 */
@Aspect //使用注解实现异常抛出增强
public class ErrorLogger {
    private static final Logger log = Logger.getLogger(ErrorLogger.class);

    @AfterThrowing(pointcut = "execution(* com.hzy.service.UserService.*(..))",throwing = "e")
    public void afterThrowing(JoinPoint jp, RuntimeException e) {
        log.error(jp.getSignature().getName() + " 方法发生异常:" + e);
    }
}
